home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2007 December / PCWKCD1207B.iso / Blogowanie poza sfera / Flock 0.9.1.3 stable / flock-0.9.1.3.en-US.win32.exe / flock / components / flockLogger.js < prev    next >
Text File  |  2007-10-12  |  4KB  |  148 lines

  1. //
  2. // BEGIN FLOCK GPL
  3. // 
  4. // Copyright Flock Inc. 2005-2007
  5. // http://flock.com
  6. // 
  7. // This file may be used under the terms of of the
  8. // GNU General Public License Version 2 or later (the "GPL"),
  9. // http://www.gnu.org/licenses/gpl.html
  10. // 
  11. // Software distributed under the License is distributed on an "AS IS" basis,
  12. // WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  13. // for the specific language governing rights and limitations under the
  14. // License.
  15. // 
  16. // END FLOCK GPL
  17. //
  18.  
  19. const Cc = Components.classes;
  20. const Ci = Components.interfaces;
  21.  
  22. const CLASS_ID    = Components.ID("{05428cec-9fd4-4955-afc9-eaaf4c6d9f9d}");
  23. const CLASS_NAME  = "Flock Logger";
  24. const CONTRACT_ID = "@flock.com/logger;1";
  25.  
  26. function flockLogger()
  27. {
  28.   this._service = Cc["@flock.com/logging-service;1"].getService(Ci.flockILoggingService);
  29. }
  30.  
  31. flockLogger.prototype = {
  32.  
  33.   _service: null,
  34.   _context: null,
  35.  
  36.   init: function(aContext)
  37.   {
  38.     this._context = aContext;
  39.   },
  40.  
  41.   debug: function(aMessage)
  42.   {
  43.     this._service.log(this._service.LEVEL_DEBUG, this._context, aMessage);
  44.   },
  45.  
  46.   info: function(aMessage)
  47.   {
  48.     this._service.log(this._service.LEVEL_INFO, this._context, aMessage);
  49.   },
  50.  
  51.   warn: function(aMessage)
  52.   {
  53.     this._service.log(this._service.LEVEL_WARN, this._context, aMessage);
  54.   },
  55.  
  56.   error: function(aMessage)
  57.   {
  58.     this._service.log(this._service.LEVEL_ERROR, this._context, aMessage);
  59.   },
  60.  
  61.   fatal: function(aMessage)
  62.   {
  63.     this._service.log(this._service.LEVEL_FATAL, this._context, aMessage);
  64.   },
  65.  
  66.   // nsIClassInfo
  67.   getInterfaces: function(aCount)
  68.   {
  69.     var interfaces = [Ci.flockILogger, Ci.nsIClassInfo];
  70.     aCount.value = interfaces.length;
  71.     return interfaces;
  72.   },
  73.  
  74.   // nsIClassInfo
  75.   getHelperForLanguage: function(aLanguage)
  76.   {
  77.     return null;
  78.   },
  79.  
  80.   // nsIClassInfo
  81.   contractID: CONTRACT_ID,
  82.  
  83.   // nsIClassInfo
  84.   classDescription: CLASS_NAME,
  85.  
  86.   // nsIClassInfo
  87.   classID: CLASS_ID,
  88.  
  89.   // nsIClassInfo
  90.   implementationLanguage: Components.interfaces.nsIProgrammingLanguage.JAVASCRIPT,
  91.  
  92.   // nsIClassInfo
  93.   flags: null,
  94.   
  95.   // nsISupports
  96.   QueryInterface: function(aIID)
  97.   {
  98.     if (!aIID.equals(Ci.nsISupports) && !aIID.equals(Ci.flockILogger) && !aIID.equals(Ci.nsIClassInfo))
  99.       throw Components.results.NS_ERROR_NO_INTERFACE;
  100.     return this;
  101.   }
  102.  
  103. };
  104.  
  105. /******************************************************************************
  106.  * XPCOM Functions for construction and registration
  107.  ******************************************************************************/
  108. var Module = {
  109.   _firstTime: true,
  110.   registerSelf: function(aCompMgr, aFileSpec, aLocation, aType)
  111.   {
  112.     if (this._firstTime) {
  113.       this._firstTime = false;
  114.       throw Components.results.NS_ERROR_FACTORY_REGISTER_AGAIN;
  115.     }
  116.     aCompMgr = aCompMgr.QueryInterface(Components.interfaces.nsIComponentRegistrar);
  117.     aCompMgr.registerFactoryLocation(CLASS_ID, CLASS_NAME, CONTRACT_ID, aFileSpec, aLocation, aType);
  118.   },
  119.  
  120.   unregisterSelf: function(aCompMgr, aLocation, aType)
  121.   {
  122.     aCompMgr = aCompMgr.QueryInterface(Components.interfaces.nsIComponentRegistrar);
  123.     aCompMgr.unregisterFactoryLocation(CLASS_ID, aLocation);        
  124.   },
  125.   
  126.   getClassObject: function(aCompMgr, aCID, aIID)
  127.   {
  128.     if (!aIID.equals(Components.interfaces.nsIFactory))
  129.       throw Components.results.NS_ERROR_NOT_IMPLEMENTED;
  130.     if (aCID.equals(CLASS_ID))
  131.       return Factory;
  132.     throw Components.results.NS_ERROR_NO_INTERFACE;
  133.   },
  134.  
  135.   canUnload: function(aCompMgr) { return true; }
  136. };
  137.  
  138. var Factory = {
  139.   createInstance: function(aOuter, aIID)
  140.   {
  141.     if (aOuter != null)
  142.       throw Components.results.NS_ERROR_NO_AGGREGATION;
  143.     return (new flockLogger()).QueryInterface(aIID);
  144.   }
  145. };
  146.  
  147. function NSGetModule(aCompMgr, aFileSpec) { return Module; }
  148.